/* VBPRINT.DLL v2.0 Last Updated 05-30-1996 by Robert Simpson
This version designed for 16-bit Windows apps.
NOTES
This program, though designed for Win3.x will work properly
with the expanded DEVMODE structure in Windows 95 and/or Win NT.
However, if you wish to access any of the extra items in the Win95
DEVMODE structure, I highly recommend using the full 32-bit version
of this DLL.
The sample programs, DLL files and all source code have been released
to the public domain.
This DLL was written and compiled in Borland C++ 4.5
*/
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include "vbapi.h"
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <dos.h>
#include <print.h>
/* Exported Functions are listed below, here are the proper VB declares:
Declare Function VBGetPrinters Lib "vbprint.dll" () As String
Declare Function VBGetDriverFromName Lib "vbprint.dll" (printername As String) As String
Declare Function VBSetDefPrinter Lib "vbprint.dll" (printername As String) As Integer
Declare Function VBGetDefPrinter Lib "vbprint.dll" () As String
Declare Function VBExtDeviceMode Lib "vbprint.dll" (ByVal hWnd As Integer, printername As String, inDev As DEVMODE_TYPE, outDev As DEVMODE_TYPE, ByVal fMode As Integer) As Integer
Declare Function VBDevModeToStr Lib "vbprint.dll" (inDev As DEVMODE_TYPE) As String
Declare Function VBStrToDevMode Lib "vbprint.dll" (dmString As String, outDev As DEVMODE_TYPE) As Integer
Declare Function VBDeviceCapabilities Lib "vbprint.dll" (printername As String, ByVal iCap As Integer, lpStr As Any, inDev As DEVMODE_TYPE) As Long
Declare Function VBResetDC Lib "vbprint.dll" (ByVal hDC As Integer, outDev As DEVMODE_TYPE) As Integer
' Here is the VB DEVMODE that should be used in all calls to this DLL requiring a DEVMODE structure:
Type DEVMODE_TYPE
dmDeviceName As String * 32
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmPrivate As String
End Type
' The DEVMODE_TYPE structure in VB is essentially a base DEVMODE structure with a dynamic
' string attached to the end (the C version is directly below, named VBDEVMODE) which
' holds the printer's private data (if there is any).
*/
#define PRINTERLIST 2048 // Size of the buffer that holds the available printers
struct VBDEVMODE // The C equivilent to the VB DEVMODE_TYPE structure above
{
DEVMODE dm; // The size of the DEVMODE structure is larger in Win95 than in Win31
HLSTR dmPrivate; // To compensate for size differences, this dmPrivate area holds the extra data
}; // required by Win95 and by the specific printer driver (if it DOES require anything).
// Exported functions
HLSTR FAR PASCAL _export VBGetPrinters();
HLSTR FAR PASCAL _export VBGetDriverFromName(HLSTR printername);
int FAR PASCAL _export VBSetDefPrinter(HLSTR);
HLSTR FAR PASCAL _export VBGetDefPrinter();
int FAR PASCAL _export VBExtDeviceMode(HWND,HLSTR,struct VBDEVMODE *,struct VBDEVMODE *,WORD);
HLSTR FAR PASCAL _export VBDevModeToStr(struct VBDEVMODE *);
int FAR PASCAL _export VBStrToDevMode(HLSTR,struct VBDEVMODE *);
long FAR PASCAL _export VBDeviceCapabilities(HLSTR,WORD,LPSTR,struct VBDEVMODE *);
int FAR PASCAL _export VBResetDC(HDC, struct VBDEVMODE *);
// Internal functions
int GetDriverFromName(HLSTR,char *,char *,char *);
DEVMODE *GetVBDevMode(struct VBDEVMODE *);
void SetVBDevMode(DEVMODE *,struct VBDEVMODE *);
typedef int (FAR PASCAL *ExtDeviceMode)(HWND,HANDLE,LPDEVMODE,LPSTR,LPSTR,LPDEVMODE,LPSTR,WORD);